{extend name="base" /}
{block name="title"}
<title>提现列表</title>
{/block}
{block name="content"}

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>提现列表 </legend> <br>
    <!--<a href="{:url('admin/cash/add')}" class="layui-btn">添加提现</a>-->
    <a href="{:url('admin/cash/index')}" class="layui-btn layui-btn-normal" target="">提现列表</a>
</fieldset>

<table class="layui-table">
    <colgroup>
        <col width="50">
        <col width="150">
        <col width="200">
        <col width="100">
        <col width="100">
        <col width="150">
    </colgroup>
    <thead>
    <tr>
        <th class="tc">ID</th>
        <th>支付宝账号</th>
        <th>支付宝订单号</th>
        <th>提现金额</th>
        <th>提现时间</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    {foreach name="list" item="v"}
    <tr>
        <td class="tc">{$v.id}</td>
        <td>{$v.alipay}</td>
        <td>{$v.alipay_sn}</td>
        <td>{$v.money}</td>
        <td>{$v.create_time}</td>
        <td>
            {if $v.pay_status == 0}<a class="layui-btn layui-btn-small" onclick="confirmAction('{$v.id}')">确认打款</a>{else/}<a class="layui-btn layui-btn-small">已打款</a>{/if}
            <!--<a href="{:url('admin/cash/edit', ['id' => $v->id])}" class="layui-btn layui-btn-small layui-btn-normal" title="修改"><i class="layui-icon"></i>修改</a>-->
            <a class="layui-btn layui-btn-small layui-btn-danger" onclick="deleteAction('{$v->id}')"><i class="layui-icon"></i>删除</a>
        </td>
    </tr>
    {/foreach}
    <tr>
        <td colspan="6">
            <div id="pages"></div>
        </td>
    </tr>
    </tbody>
</table>

{/block}

{block name="js"}
<script type="text/javascript" src="/public/admin/js/jquery.min.js"></script>
<script>
    layui.use(['form', 'layedit', 'laydate','element','laypage','layer'], function () {
        var form = layui.form, $ = layui.jquery,laypage = layui.laypage;
        //完整功能
        laypage.render({
            elem: 'demo7'
            ,count: 100
            ,layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
            ,jump: function(obj){
                console.log(obj)
            }
        });
        laypage.render({
            elem: 'pages',
            cont: 'pages'
            ,curr: '{$page.currentPage}'  //当前页
            ,pages: '{$page.pageCount}'  //总页数
            ,skip: true
            ,jump: function(obj, first){
                if(!first){
                    //layer.msg('第 '+ obj.curr +' 页');
                    location.href="{:url('order/index')}?page="+obj.curr;
                }
            }
        });
        //监听提交
        form.on('submit(sub)', function (data) {
            return true;
        });

    });

    function changeOrder(obj, id) {
        var order = $(obj).val();
        $.post("{:url('admin/common/change_order')}",{'type':'lunbo','id':id,'order':order,'field':'sort_order'}, function (data) {
            layer.msg(data.msg);
        },'json')
    }
    function confirmAction(id) {
        //询问框
        layer.confirm('您确定通过审核这个提现吗？', {
            btn: ['确定', '取消'] //按钮
        }, function () {
            //发送post请求
            $.post("{:url('admin/cash/check')}", {_method: 'POST', '_token': 'csrf_token', id: id}, function (data) {
                if (data.errno) {
                    layer.msg(data.msg, {icon: 2});
                } else {
                    layer.msg('审核成功', {icon: 1});
                    location.href = location.href;
                }
            }, 'json');
        }, function () {
            //layer.msg('11', {icon: 2});
        });
    }
    function deleteAction(id) {
        //询问框
        layer.confirm('您确定要删除这个提现吗？', {
            btn: ['确定','取消'] //按钮
        }, function(){
            //发送post请求
            $.post("{:url('admin/cash/delete')}", {_method:'DELETE','_token':'csrf_token',id:id}, function (data) {
                if(data.errno) {
                    layer.msg(data.msg, {icon: 2});
                }else {
                    layer.msg('删除成功', {icon: 1});
                    location.href=location.href;
                }
            },'json');
        }, function(){
            //layer.msg('11', {icon: 2});
        });
    }
</script>
{/block}